//
//  NSString+LLMD5.m
//  live.ly
//
//  Created by bob on 16/6/1.
//  Copyright © 2016年 musical.ly. All rights reserved.
//

#import "NSString+LLMD5.h"
#import <CommonCrypto/CommonDigest.h>


@implementation NSString (LLMD5)

- (NSString *)ll_MD5Digest
{
    const char *input = [self UTF8String];
    unsigned char result[CC_MD5_DIGEST_LENGTH];
    CC_MD5(input, (CC_LONG)strlen(input), result);

    NSMutableString *digest = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH * 2];
    for (NSInteger i = 0; i < CC_MD5_DIGEST_LENGTH; i++) {
        [digest appendFormat:@"%02x", result[i]];
    }

    return digest;
}

@end
